home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8819 < prev    next >
Encoding:
Text File  |  1996-08-05  |  972 b   |  33 lines

  1. Path: dialin1-45.wustl.edu!user
  2. From: rdk2@cec.wustl.edu (Rob Klapper)
  3. Newsgroups: comp.lang.c++
  4. Subject: Passing a type-specifier as an argument?!?
  5. Date: Mon, 26 Feb 1996 15:06:44 -0600
  6. Organization: Washington University in St. Louis, MO USA
  7. Message-ID: <rdk2-2602961506440001@dialin1-45.wustl.edu>
  8. NNTP-Posting-Host: @dialin1-45.wustl.edu
  9.  
  10.    OK, here's the deal, essentially, I would like to have a function
  11. _ones() which could be called like _ones(int), to return an int with its
  12. bit pattern all ones.  I've tried various way to pass just a
  13. type-specifier as an argument, but to no avail.
  14.  
  15. The way I do this now is:
  16.  
  17. #define _ones(t) _onesguts(t(0))
  18.  
  19. template <class T>
  20. T _onesguts(T n){
  21.    // stuff...
  22. }
  23.  
  24. What I would like to know is if there is a way to get around having to use
  25. a define to do this.  Any help is geatly appreciated...
  26.  
  27. -- 
  28. Robert D. Klapper
  29. rdk2@cec.wustl.edu
  30. http://www.cec.wustl.edu/~rdk2
  31.  
  32. The Murphy Philosophy:  Smile. Tommorrow will be worse.
  33.